package com.imis.module.system.model.converter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imis.base.constant.ConverterIgnoreConstant;
import com.imis.module.system.model.po.SysDict;
import com.imis.module.system.model.po.SysDictItem;
import com.imis.module.system.model.ro.SysDictAddRO;
import com.imis.module.system.model.ro.SysDictItemAddRO;
import com.imis.module.system.model.ro.SysDictItemUpdateRO;
import com.imis.module.system.model.ro.SysDictUpdateRO;
import com.imis.module.system.model.vo.SysDictItemVO;
import com.imis.module.system.model.vo.SysDictVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * <p>
 * 字典项 Converter 转换器
 * </p>
 *
 * @author XinLau
 * @since 2020-03-23
 */
@Mapper
public interface SysDictConverter {

    /**
     * 字典 转换器实例
     */
    SysDictConverter INSTANCE = Mappers.getMapper(SysDictConverter.class);

    /**
     * 字典项 PO转VO
     *
     * @param entity - 字典项
     * @return SysDictVO
     */
    @Mappings({})
    SysDictVO domain2Vo(SysDict entity);

    /**
     * 字典项 PO转VO
     *
     * @param sysDictList - 字典项
     * @return List<SysDictVO>
     */
    @Mappings({})
    List<SysDictVO> domains2Vos(List<SysDict> sysDictList);

    /**
     * 字典值 PO转VO
     *
     * @param entity - 字典值
     * @return SysDictItemVO
     */
    @Mappings({})
    SysDictItemVO domain2vo(SysDictItem entity);

    /**
     * 字典值 PO转VO
     *
     * @param sysDictItemList - 字典值
     * @return List<SysDictVO>
     */
    @Mappings({})
    List<SysDictItemVO> domains2vos(List<SysDictItem> sysDictItemList);

    /**
     * 字典项 PO转VO
     *
     * @param sysDictPage - 字典项
     * @return List<SysDictVO>
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.ASCS, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.ASC, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.DESCS, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.DESC, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.OPTIMIZE_COUNT_SQL, ignore = true)
    })
    Page<SysDictVO> pagePo2pageVo(Page<SysDict> sysDictPage);

    /**
     * 字典项 RO转PO
     *
     * @param sysDictAddRO - 字典项添加对象
     * @return SysDict
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.ID, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.CREATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.CREATE_TIME, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_TIME, ignore = true)
    })
    SysDict addRo2domain(SysDictAddRO sysDictAddRO);

    /**
     * 字典值 RO转PO
     *
     * @param sysDictItemAddRO - 字典值添加对象
     * @return SysDict
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.ID, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.CREATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.CREATE_TIME, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_TIME, ignore = true)
    })
    SysDictItem addRo2domain(SysDictItemAddRO sysDictItemAddRO);

    /**
     * 字典项 RO转VO
     *
     * @param sysDictAddRO - 字典项添加对象
     * @return SysDict
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.ID, ignore = true)
    })
    SysDictVO addRo2Vo(SysDictAddRO sysDictAddRO);

    /**
     * 字典值 RO转VO
     *
     * @param sysDictItemAddRO - 字典值添加对象
     * @return SysDict
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.ID, ignore = true)
    })
    SysDictItemVO addRo2Vo(SysDictItemAddRO sysDictItemAddRO);

    /**
     * 字典项 RO转VO
     *
     * @param sysDictUpdateRO - 字典项修改对象
     * @return SysDict
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.CREATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.CREATE_TIME, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_TIME, ignore = true)
    })
    SysDict updateRo2domain(SysDictUpdateRO sysDictUpdateRO);

    /**
     * 字典值 PO转VO
     *
     * @param sysDictItemPage - 字典值
     * @return List<SysDictItemVO>
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.ASCS, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.ASC, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.DESCS, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.DESC, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.OPTIMIZE_COUNT_SQL, ignore = true)
    })
    Page<SysDictItemVO> pagePo2PageVo(Page<SysDictItem> sysDictItemPage);

    /**
     * 字典项 RO转VO
     *
     * @param sysDictItemUpdateRO - 字典值修改对象
     * @return SysDict
     */
    @Mappings({
            @Mapping(target = ConverterIgnoreConstant.CREATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.CREATE_TIME, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_BY, ignore = true),
            @Mapping(target = ConverterIgnoreConstant.UPDATE_TIME, ignore = true)
    })
    SysDictItem updateRo2domain(SysDictItemUpdateRO sysDictItemUpdateRO);

}
